package com.aiyige.page.publish.selectcoursetype.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.publish.selectcoursetype.model.CourseTypeItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhuyakun on 2017/11/8.
 */

public class SelectCourseTypeAdapter extends BaseQuickAdapter<CourseTypeItem, SelectCourseTypeAdapter.ViewHolder> {


    public SelectCourseTypeAdapter() {
        super(R.layout.course_type_item, new LinkedList<CourseTypeItem>());
    }

    @Override
    protected void convert(ViewHolder helper, CourseTypeItem item) {
        helper.bindData(item);
    }

    public class ViewHolder extends BaseViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.addIv)
        ImageView addIv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(CourseTypeItem data) {
            switch (data.getType()) {
                case CourseTypeItem.TYPE_ADD: {
                    titleTv.setVisibility(View.GONE);
                    addIv.setVisibility(View.VISIBLE);
                    break;
                }
                case CourseTypeItem.TYPE_NORMAL: {
                    titleTv.setVisibility(View.VISIBLE);
                    addIv.setVisibility(View.GONE);
                    titleTv.setText(data.getTitle());
                    titleTv.setSelected(data.isSelected());
                    break;
                }
            }
        }
    }

}
